/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package Service;

import javax.naming.NamingException;
import javax.servlet.http.HttpServletRequest;
import th.co.tac.esv.pre.ejb.dat.dprompt.chng.password.DpromptChngPasswordRequest;
import th.co.tac.esv.pre.ejb.dat.dprompt.chng.password.DpromptChngPasswordResponse;
import th.co.tac.esv.pre.ejb.itf.dprompt.chng.password.DpromptChngPasswordBeanRemote;

/**
 *
 * @author Peat
 */
public class UserProfileService extends BaseService
{
    public DpromptChngPasswordResponse changePassword(
            HttpServletRequest httpRequest) throws NamingException
    {
        this.readyEJB(null);
        
        if (!cache.containsKey("DpromptChngPasswordResponse")) {
            DpromptChngPasswordRequest reqs = new DpromptChngPasswordRequest();
            reqs.setUserName(httpRequest.getParameter("username"));
            reqs.setSubrNumb(httpRequest.getParameter("username"));
            reqs.setPassword(httpRequest.getParameter("newpassword"));
            reqs.setOldPassword(httpRequest.getParameter("password"));
            reqs.setFuncID("");
            reqs.setMenuID("");

            DpromptChngPasswordBeanRemote bean = (DpromptChngPasswordBeanRemote)
                    ic.lookup("JNDIDpromptChngPasswordBean");
            DpromptChngPasswordResponse resp = bean.getCallDpromptChngPassword(reqs);

            cache.put("DpromptChngPasswordResponse", resp);
        }
        return (DpromptChngPasswordResponse) cache.get("DpromptChngPasswordResponse");
    }
}
